package datalookin.adapter2;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.whu.zj.MyApplication;
import com.whu.zj.R;

import java.util.ArrayList;
import java.util.List;

import datalookin.dto2.StationAllDataDto;

/**
 * Created by Administrator on 2016/6/5.
 */
public class RealStationAdapter extends BaseAdapter {

    List<StationAllDataDto> stationAllDataDtos = new ArrayList<StationAllDataDto>();

    public void setStationAllDataDtos(List<StationAllDataDto> stationAllDataDtos) {
        this.stationAllDataDtos = stationAllDataDtos;
    }

    @Override
    public int getCount() {
        return stationAllDataDtos.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View convertView, ViewGroup viewGroup) {
        ViewHolder viewHolder = null;
        if (convertView == null)
        {
            convertView = View.inflate(MyApplication.share(), R.layout.item_realstation,null);
            viewHolder = new ViewHolder();
            viewHolder.name1 = (TextView) convertView.findViewById(R.id.tv_name1);
            viewHolder.value1 = (TextView) convertView.findViewById(R.id.tv_value1);
            viewHolder.name2 = (TextView) convertView.findViewById(R.id.tv_name2);
            viewHolder.value2 = (TextView) convertView.findViewById(R.id.tv_value2);
            viewHolder.value3 = (TextView) convertView.findViewById(R.id.tv_value3);

            convertView.setTag(viewHolder);
        }
        else
        {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        StationAllDataDto stationAllDataDto = stationAllDataDtos.get(i);
        viewHolder.name1.setText(stationAllDataDto.getStationnum()==null?"无":stationAllDataDto.getStationnum());
        viewHolder.value1.setText(stationAllDataDto.getPressureValue()==null?"无":stationAllDataDto.getPressureValue());
        viewHolder.name2.setText(stationAllDataDto.getFlowValue()==null?"无":stationAllDataDto.getFlowValue());
        viewHolder.value2.setText(stationAllDataDto.getTurbidityValue()==null?"无":stationAllDataDto.getTurbidityValue());
        viewHolder.value3.setText(stationAllDataDto.getChlorineValue()==null?"无":stationAllDataDto.getChlorineValue());

        return convertView;
    }


    class ViewHolder
    {
        TextView name1;
        TextView value1;
        TextView name2;
        TextView value2;
        TextView value3;
    }


}
